package demo;

import com.rabbitmq.client.*;
import jdk.internal.org.objectweb.asm.Handle;
import util.ConncetionUtil;

import java.io.IOException;

public class Consumer {
    private static final String QUEUENAME="zfz";

    public static void main(String[] args) throws Exception {
        Connection connection = ConncetionUtil.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(QUEUENAME,false,false,false,null);
        channel.basicConsume(QUEUENAME,true, new DefaultConsumer(channel){
            @Override
            public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
                //重写这个方法就是为了自定义处理收到的消息怎么操作
                System.err.println("张飞正大土豪收到的消息是:"+new String(body));
            }
        });



    }

}
